//
//  ConsultSegmentController.m
//  soccer
//
//  Created by 上官千城 on 15/9/7.
//  Copyright (c) 2015年 上官千城. All rights reserved.
//

#import "OConsultSegmentController.h"

@interface OConsultSegmentController ()

@end

@implementation OConsultSegmentController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    //更改NAV title 字体大小和颜色
    self.navigationController.navigationBar.titleTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:20],NSForegroundColorAttributeName:[UIColor whiteColor]};
    
    //左侧按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:[UIImage imageNamed:@"402"]
                      forState:UIControlStateNormal];
    [button addTarget:self action:@selector(leftBarButtonItemAction)
     forControlEvents:UIControlEventTouchUpInside];
    button.frame = CGRectMake(0, 0, 40, 40);
    
    UIBarButtonItem *left = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.leftBarButtonItem = left;

    
    //右侧按钮
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button1 setBackgroundImage:[UIImage imageNamed:@"manpage_032@2x"]forState:UIControlStateNormal];
//    button1.backgroundColor = RGBACOLOR(189, 213, 216, 1);
    [button1 addTarget:self action:@selector(PublishButton)
     forControlEvents:UIControlEventTouchUpInside];
    button1.frame = CGRectMake(0, 0, 40, 40);
    UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithCustomView:button1];
    self.navigationItem.rightBarButtonItem = right;


    //容器视图控制器
    self.discoveryView = [[ODiscoveryController alloc]init];
    [self addChildViewController:self.discoveryView];
    [self.view addSubview:self.discoveryView.view];
    
    self.consultView = [[OConsultViewController alloc]init];
    [self addChildViewController:self.consultView];
    [self.view addSubview:self.consultView.view];
    
    NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"资讯",@"发现", nil];
    UISegmentedControl *segment = [[UISegmentedControl alloc]initWithItems:arr];
    segment.backgroundColor = [UIColor clearColor];
    segment.selectedSegmentIndex = 0;
    segment.frame = CGRectMake(0, 0, 120, 30);
    segment.tintColor = RGBACOLOR(189, 213, 216, 1);
//    segment.layer.masksToBounds = YES;
//    segment.layer.cornerRadius = 8;
    self.navigationItem.titleView = segment;
    [segment addTarget:self action:@selector(segmentButton:) forControlEvents:UIControlEventValueChanged];
    
    
    
}
//切换标题
-(void)segmentButton:(UISegmentedControl *)Seg
{
    NSInteger index = Seg.selectedSegmentIndex;
    switch (index) {
        case 0:
            [self.view bringSubviewToFront:self.consultView.view];
            break;
        case 1:
            [self.view bringSubviewToFront:self.discoveryView.view];
            break;
        default:
            break;
    }
    
    
}
//发送资讯
-(void)PublishButton
{
    OPublishController *view = [[OPublishController alloc]init];
    view.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:view animated:YES];
}



//抽屉方法
-(void)leftBarButtonItemAction
{
    [self.sideMenuViewController presentLeftMenuViewController];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
